package encaps.action;

import encaps.entities.Grant;
import encaps.resources.Image;
import encaps.resources.Labels;
import encaps.resources.Response;
import encaps.utils.XMLHelper;
import org.jdom.Element;

public class ShowEmptyPersonPageAction extends Action {

    public static final String SHOW_EMPTY_PERSON_PAGE = "showEmptyPersonPage";
    public static final String PERSON_PIC = "pic";
    public static final String PERSON_NAME = "name";
    public static final String PERSON_BIOGRAPHY = "biography";
    protected ActionContext actionContext;

    public ShowEmptyPersonPageAction(ActionContext context, Grant requiredGrant) {
        this.actionContext = context;
        this.requiredGrant = requiredGrant;
    }

    @Override
    public Element execute() throws ActionExecutionException {
        Element response = XMLHelper.createElement(Response.RESPONSE);
        Element e = XMLHelper.addChild(response, Response.ENTITY);
        e.setAttribute(Response.EDIT, "true");

        XMLHelper.addChild(e, XMLHelper.createHeader(Labels.getLabel(Labels.CREATE_PERSON)));
        XMLHelper.addChild(e, XMLHelper.createImage("", PERSON_PIC));
        XMLHelper.addChild(e, XMLHelper.createTextField(Labels.getLabel(Labels.PERSON_NAME), null, PERSON_NAME));
        XMLHelper.addChild(e, XMLHelper.createTextArea(Labels.getLabel(Labels.PERSON_BIOGRAPHY), null, PERSON_BIOGRAPHY));

        XMLHelper.addChild(e, XMLHelper.createImageButton(Image.getImage(Image.CREATE_PERSON), CreatePersonAction.CREATE_PERSON));

        return response;
    }
}
